import { EnumSchema } from '@/utils/common/types';
import { PresetColorEnum } from '@/enums/colorEnum';

//#region 库区类型
export enum WareHouseAreaTypeEnum {
  ElectronicMaterial = 0,
  MechanismMaterial,
  DevelopmentBoard,
  CompetingGoods,
  Instrument,
  Tool,
  OfficeSupplies,
}

export class WareHouseAreaTypeEntity {
  Type: WareHouseAreaTypeEnum;
  /** 显示描述 */
  Display: string;
  /** 颜色 */
  Color?: PresetColorEnum | string;

  constructor(wareHouseAreaType: WareHouseAreaTypeEnum, color?: PresetColorEnum | string) {
    this.Type = wareHouseAreaType;
    this.Color = color;
    switch (wareHouseAreaType) {
      case WareHouseAreaTypeEnum.ElectronicMaterial:
        this.Display = '电子物料';
        this.Color = this.Color ? this.Color : PresetColorEnum.Green;
        break;
      case WareHouseAreaTypeEnum.MechanismMaterial:
        this.Display = '机构物料';
        this.Color = this.Color ? this.Color : PresetColorEnum.Blue;
        break;
      case WareHouseAreaTypeEnum.DevelopmentBoard:
        this.Display = '开发板';
        this.Color = this.Color ? this.Color : PresetColorEnum.Cyan;
        break;
      case WareHouseAreaTypeEnum.CompetingGoods:
        this.Display = '竞品';
        this.Color = this.Color ? this.Color : PresetColorEnum.Geekblue;
        break;
      case WareHouseAreaTypeEnum.Instrument:
        this.Display = '仪器';
        this.Color = this.Color ? this.Color : PresetColorEnum.Lime;
        break;
      case WareHouseAreaTypeEnum.Tool:
        this.Display = '工具';
        this.Color = this.Color ? this.Color : PresetColorEnum.Magenta;
        break;
      case WareHouseAreaTypeEnum.OfficeSupplies:
        this.Display = '办公用品';
        this.Color = this.Color ? this.Color : PresetColorEnum.Pink;
        break;
    }
  }
}

export function getWareHouseAreaTypeEnumSchema(enableTag = true): EnumSchema[] {
  const enumSchema: EnumSchema[] = [];
  const typeEntities: WareHouseAreaTypeEntity[] = [
    new WareHouseAreaTypeEntity(WareHouseAreaTypeEnum.ElectronicMaterial),
    new WareHouseAreaTypeEntity(WareHouseAreaTypeEnum.MechanismMaterial),
    new WareHouseAreaTypeEntity(WareHouseAreaTypeEnum.DevelopmentBoard),
    new WareHouseAreaTypeEntity(WareHouseAreaTypeEnum.CompetingGoods),
    new WareHouseAreaTypeEntity(WareHouseAreaTypeEnum.Instrument),
    new WareHouseAreaTypeEntity(WareHouseAreaTypeEnum.Tool),
    new WareHouseAreaTypeEntity(WareHouseAreaTypeEnum.OfficeSupplies),
  ];
  typeEntities.forEach((item) => {
    enumSchema.push({
      key: item.Type as number,
      label: item.Display,
      value: item.Type as number,
      tag: enableTag,
      tagColor: item.Color,
    });
  });
  return enumSchema;
}
//#endregion
